<!--
 * @Description: 
 * @Date: 2024-07-08 17:02:26
 * @LastEditTime: 2024-07-10 17:57:44
-->
<script setup lang="ts">
import * as ReportApi from '@/api/countryside/disclosureaffairs/index'
import { formatTime } from '@/utils'
const dictType = {
  1: 'SYSTEM_CUNWU_TYPE',
  2: 'SYSTEM_DANGWU_TYPE',
  3: 'SYSTEM_CAIWU_TYPE'
}

import { DICT_TYPE } from '@/utils/dict'
const dialogVisible = ref(false) // 弹窗的是否展示
const form = reactive({
  type: 0,
  labelType: 0,
  pushTime: '',
  author: '',
  readCount: '',
  stick: '',
  largeScreen: '',
  title: '',
  content: ''
})
/** 打开弹窗 */
const open = async (id?: number) => {
  dialogVisible.value = true
  // 修改时，设置数据
  if (id) {
    try {
      const data = await ReportApi.getReport(id)
      data.type = Number(data.type)
      data.labelType = Number(data.labelType)
      Object.assign(form, data)
    } finally {
    }
  }
}
defineExpose({ open }) // 提供 open 方法，用于打开弹窗
</script>

<template>
  <Dialog title="详情" v-model="dialogVisible">
    <div>
      <el-descriptions :column="2" border>
        <el-descriptions-item label="事务类型">
          <dict-tag :type="DICT_TYPE.COUNTRYSIDE_AFFAIR_TYPE" :value="form.type" />
        </el-descriptions-item>
        <el-descriptions-item label="标签类型">
          <dict-tag :type="DICT_TYPE[dictType[form['type']]]" :value="form.labelType" />
        </el-descriptions-item>
        <el-descriptions-item label="发布时间">
          {{ formatTime(form.pushTime, 'yyyy-MM-dd HH:mm:ss') }}
        </el-descriptions-item>
        <el-descriptions-item label="发布人">{{ form.author }}</el-descriptions-item>
        <el-descriptions-item label="阅读人数">{{ form.readCount }}</el-descriptions-item>
        <el-descriptions-item label="是否置顶">
          <dict-tag :type="DICT_TYPE.SYSTEM_WHETHER_TYPE" :value="form.stick" />
        </el-descriptions-item>
        <el-descriptions-item label="是否大屏展示" :span="2">
          <dict-tag :type="DICT_TYPE.SYSTEM_WHETHER_TYPE" :value="form.largeScreen" />
        </el-descriptions-item>
        <el-descriptions-item label="标题" :span="2">{{ form.title }}</el-descriptions-item>
        <el-descriptions-item label="内容" :span="2">
          <div v-html="form.content"></div>
        </el-descriptions-item>
      </el-descriptions>
    </div>
  </Dialog>
</template>

<style scoped lang="scss"></style>
